package com.binhai.db;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;

@Component
public class SpringDB {
    //数据源DataSource
    @Autowired
    private DataSource dataSource;

    public DataSource getDataSource() {
        return dataSource;
    }

    public void setDataSource(DataSource dataSource) {

        this.dataSource = dataSource;
    }
    //生成JdbcTemplate对象
    public JdbcTemplate getJdbcTemplate() {

        return new JdbcTemplate(this.getDataSource());
    }
}
